package cn.iocoder.yudao.module.system.controller.admin.tenant;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.institution.InstitutionPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.institution.InstitutionRespVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.institution.InstitutionSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.InstitutionDO;
import cn.iocoder.yudao.module.system.service.tenant.InstitutionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 机构管理")
@RestController
@RequestMapping("/app/institution/")
@Validated
public class AppInstitutionController {

    @Resource
    private InstitutionService institutionService;


    @GetMapping("/get")
    @Operation(summary = "获得机构管理")





    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<InstitutionRespVO> get(@RequestParam("id") Long id) {
        InstitutionDO institutionDO = institutionService.get(id);
        return success(BeanUtils.toBean(institutionDO, InstitutionRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得机构管理")
    @PermitAll
    public CommonResult<List<InstitutionDO>> getList(@Valid InstitutionRespVO institutionRespVO) {
        return success(institutionService.getList(institutionRespVO));
    }


}